# THIS IS A SOURCE CODE FILE FROM I'M NOT EVEN HUMAN THE GAME.
# IT COULD BE USED IN A DIFFERENT PIECE OF SOFTWARE ( LIKE A
# DIFFERENT GAME ), BUT IT WAS ORIGINALLY WRITTEN FOR I'M NOT
# EVEN HUMAN THE GAME.

# THE DEVELOPERS OF THE GAME ARE : (C) J.Y.AMIHUD, AYYZEE AND 
# OTHER CONTRIBUTORS. THIS AND OTHER FILES IN THIS GAME,
# UNLESS SPECIFICALLY NOTED, COULD BE USED UNDER THE TERMS OF
# GNU GENERAL PUBLIC LICENSE VERSION 3 OR ANY LATER VERSION.

import os

# GTK module ( Graphical interface
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import cairo

from modules import ui

def layer(game):

    # Setting up a cairo layer
    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
                                 game.current['w'],
                                 game.current['h'])
    layer = cairo.Context(surface)
    layer.set_antialias(cairo.ANTIALIAS_NONE)
    
    
    # Text settings
    layer.select_font_face("Monospace",
                           cairo.FONT_SLANT_NORMAL,
                           cairo.FONT_WEIGHT_NORMAL)
    current_fontoption = layer.get_font_options()
    current_fontoption.set_antialias(cairo.ANTIALIAS_NONE)
    layer.set_font_options(current_fontoption)

    # Background Pattern
    ui.useless_interface_1(game, layer,
                          0,0,
                          game.current['w'],
                          game.current['h'])
    
    
    
    # Title of the game

    # Graphical game title
    #ui.image(game, layer, 10, 15, "assets/game-title.png")

    if game.current["frame"] > 45:
        def do():
            game.scene = "gameplay"

        ui.button(game, layer,
                  15,                       # X
                  game.current["h"] - 52 ,  # Y
                  int(game.current["w"] / 3 ) - 14 ,  # Width
                  13,
                  icon="dpad",
                  menu="main",
                  string="Play",
                  func=do)
    if game.current["frame"] > 50:
        def do():
            game.scene = "settings"

        ui.button(game, layer,
                  15,                       # X
                  game.current["h"] - 37 ,  # Y
                  int(game.current["w"] / 3 ) - 14 ,  # Width
                  13,
                  icon="settings",
                  menu="main",
                  string="Settings",
                  func=do)
    if game.current["frame"] > 55:
        def do():
            game.destroy()

        ui.button(game, layer,
                  15,                       # X
                  game.current["h"] - 22 ,  # Y
                  int(game.current["w"] / 3 ) - 14 ,  # Width
                  13,
                  icon="cross_inverted",
                  menu="main",
                  string="Quit",
                  func=do)

    # Navigating the menus
    try:
        ui.button_navigate(game, "main")
    except:
        pass
    
    return surface
